package Class_03_29;

//final 修饰的类不能被继承
//final 修饰的方法不能被子类调用
//final 修饰的变量是常量，不能被改写

class Animal4
{
    String name;
    int age;

    public Animal4() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Animal4(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public  final void shout()
    {
        System.out.println("该动物叫声为:");
    }
}

class Dog4 extends Animal4
{
    //public void shout()   //报错，被final修饰

}


public class AnimalTest4 {
    public static void main(String[] args) {
        Dog4 dog = new Dog4();


        //final int head = 20;
        //head = 18;  //报错
    }
}
